package com.liu.concurrent.juc.atomic;

import java.util.concurrent.atomic.AtomicStampedReference;

public class AtomicStampedReferenceDemo {

    public static void main(String[] args) {


        // Integer [-128,128)
        AtomicStampedReference<Integer> atomicStampedReference = new AtomicStampedReference(127,1);

        System.out.println(atomicStampedReference.compareAndSet(127, -128,
                atomicStampedReference.getStamp(), atomicStampedReference.getStamp() + 1));

        System.out.println(atomicStampedReference.compareAndSet(-128, 127,
                atomicStampedReference.getStamp(), atomicStampedReference.getStamp() + 1));

    }
}
